//
//  OosTag.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/23/11.
//

#import <oos4ios/Model/OosTag.h>

@implementation OosTag

@dynamic label;
@dynamic term;

@dynamic users;
@dynamic reviews;

static NSString *fetchPredicate = @"term = %@";

+ (OosTag *) tagFromTerm:(NSString *)term
{
    OosTag *tag = nil; 
    tag = [super objectWithPredicate: fetchPredicate, term];
    if (tag == nil) {
        tag = [super create];
        tag.term = term;
        tag.label = term;
    }
	return tag;
}

- (NSMutableSet *)mutableReviews
{
    return [self mutableSetValueForKey:@"reviews"];
}

- (NSMutableSet *)mutableUsers
{
    return [self mutableSetValueForKey:@"users"];
}

- (NSString *) description
{
    return self.term;
}

@end
